package com.example.smartcity.search;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

import androidx.annotation.Nullable;

public class SearchDBHelper extends SQLiteOpenHelper {


    public SearchDBHelper(@Nullable Context context, @Nullable String name, @Nullable SQLiteDatabase.CursorFactory factory, int version) {
        super(context, name, factory, version);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL("CREATE TABLE searchrecord (id INTEGER PRIMARY KEY AUTOINCREMENT, title VARCHAR(100)) ;");
        Log.i("msg","创建完成");
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        db.execSQL("DROP TABLE IF EXISTS searchrecord");
        onCreate(db);
    }
    public void onDelete(SQLiteDatabase db){
        db.execSQL("DELETE FROM searchrecord");
        Log.i("clean","清除了历史记录");
    }
}
